import React from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table';
import Addserveritem from "@/pages/customerService/CustomerServiceList/components/addSeverItem";
import  { ModalForm} from '@ant-design/pro-form';
import SearchHeader from "@/pages/customerService/GuestBook/SearchHeader";
import {getGuestBook} from "@/services/ant-design-pro/customerService";



// 定义表头
// ID 昵称 电话 内容 状态 时间 操作
const columns = [
  {
    title: 'ID',
    width: 80,
    dataIndex: 'id',
    key:'id'
  },
  {
    title: '昵称',
    width: 80,
    dataIndex: 'name',
    key:'name',
  },
  {
    title: '电话',
    width: 120,
    dataIndex: 'phone',
    key: 'phone',
  },
  {
    title: '内容',
    dataIndex: 'content',
    key:'content'
  },
  {
    title: '状态',
    width:80,
    dataIndex: 'status',
    key:'status',
  },
  {
    title: '时间',
    width:100,
    dataIndex: 'updated_at',
    key:'updated_at'
  },
  {
    title: '操作',
    align:'center',
    valueType: 'option',
    fixed: 'right',
    key: 'option',
    render: () => [
      <ModalForm
        title="工作台"
        trigger={
          <span><a key="link1"> 处理 </a>  </span>
        }
      >
        <Addserveritem />
      </ModalForm>,
      <span><a key="link2"> 删除 </a>  </span>,
    ],
  },
]


const List = () => {
  return (
    <div>
      <PageContainer
        header={{
          title:'客服反馈',
          breadcrumb: {},
        }}
      >
        <SearchHeader />
        <ProTable
          columns={columns}
          request={async () => {
            // 表单搜索项会从 params 传入，传递给后端接口。
            const data = await getGuestBook()
            console.log(data)
            return Promise.resolve({
              data: data.data,
              success: true,
            });
          }}
          rowKey="key"
          pagination={{
            showQuickJumper: true,
          }}
          options={false}
          search={false}
          dateFormatter="string"
        />
      </PageContainer>
    </div>
  );
};

export default List;
